package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.*;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author xuanqicheng
 * @create 2019-21-10:04
 */
@Repository
public class FindDynamicInfoDao {

    @Autowired
    private SqlSession sqlSession;

    public void addFindDynamciInfo(FindDynamicInfo findDynamicInfo) {

        sqlSession.insert("addFindDynamciInfo",findDynamicInfo);

    }

    public int subtractionLikeNumber(int findId) {
        return sqlSession.update("findSubtractionLikeNumber",findId);
    }

    public int findAddLikeNumber(int findId){
        return sqlSession.update("findAddLikeNumber",findId);
    }

    public FindDynamicInfo getFindDynamicByFindId(int findId) {
        return sqlSession.selectOne("getFindDynamicByFindId",findId);
    }

    public List<Integer> getFindDynamicIdsPageByUserId(long userId,int startNum,int pageSize){
        Map<String,Object> parames = new HashMap<>();
        parames.put("userId",userId);
        parames.put("startNum",startNum);
        parames.put("pageSize",pageSize);
        return sqlSession.selectList("getFindDynamicPageByUserId",parames);
    }
}
